var app = getApp();
var server = require('../../util/server.js');
Page({
  data: {
    motto: 'Hello WeApp',
    userInfo: {},
    toast2Hidden:true,
    place_id:0
  },
  onButtonTap: function() {
    wx.navigateTo({
      url: '../logs/logs'
    })
  },
  onLoad: function (options) {
    this.setData({
            place_id: options.placeId
        })
    app.getUserInfo()
        .then(info => {
          console.log(info)
          this.setData({ userInfo: info })
          })
        .catch(console.info)
   console.log("run apply")
  },
  formSubmit: function(e) {
    //console.log('form发生了submit事件，携带数据为：', e.detail.value)
    var that = this;
    var parms = e.detail.value;
    server.resource('userPlace',parms,'POST').then(function(res){
        if(res.data.status == 0){
            that.setData({
              toast2Hidden:false
            });
          setTimeout(function() {
            wx.redirectTo({
              url: '/pages/list/index'
            })

          }, 1500);
        }
    });
  },
  formReset: function() {
    console.log('form发生了reset事件')
  },
  bindBeginDateChange: function(e) {
    this.setData({
      begin_date: e.detail.value
    })
  },
  bindBeginTimeChange: function(e) {
    this.setData({
      begin_time: e.detail.value
    })
  },
  bindEndDateChange: function(e) {
    this.setData({
      end_date: e.detail.value
    })
  },
  bindEndTimeChange: function(e) {
    this.setData({
      end_time: e.detail.value
    })
  }
})

